<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Hexo 搭建博客教程 | Guru Note</title>
    <meta name="generator" content="VuePress 1.7.1">
    <link rel="stylesheet" href="./font/index.css">
    <script src="/docs/icon/svg.js"></script>
    <meta name="description" content="Sea of dawn">
    
    <link rel="preload" href="/docs/assets/css/0.styles.efa081cd.css" as="style"><link rel="preload" href="/docs/assets/js/app.cdec4db9.js" as="script"><link rel="preload" href="/docs/assets/js/2.993bd611.js" as="script"><link rel="preload" href="/docs/assets/js/26.61b6eb9f.js" as="script"><link rel="preload" href="/docs/assets/js/7.5a12abef.js" as="script"><link rel="prefetch" href="/docs/assets/js/10.c3177bdb.js"><link rel="prefetch" href="/docs/assets/js/100.60c23478.js"><link rel="prefetch" href="/docs/assets/js/101.7ea29e1b.js"><link rel="prefetch" href="/docs/assets/js/102.7f47e485.js"><link rel="prefetch" href="/docs/assets/js/103.ea9ce400.js"><link rel="prefetch" href="/docs/assets/js/104.4ec6a518.js"><link rel="prefetch" href="/docs/assets/js/105.75526347.js"><link rel="prefetch" href="/docs/assets/js/106.01f6b03b.js"><link rel="prefetch" href="/docs/assets/js/107.69fe0811.js"><link rel="prefetch" href="/docs/assets/js/108.fa23768b.js"><link rel="prefetch" href="/docs/assets/js/109.90df1698.js"><link rel="prefetch" href="/docs/assets/js/11.54347528.js"><link rel="prefetch" href="/docs/assets/js/110.dd8d7227.js"><link rel="prefetch" href="/docs/assets/js/111.ccf25ceb.js"><link rel="prefetch" href="/docs/assets/js/112.6963298f.js"><link rel="prefetch" href="/docs/assets/js/113.30ceb3d8.js"><link rel="prefetch" href="/docs/assets/js/114.42ef6603.js"><link rel="prefetch" href="/docs/assets/js/115.f1db7817.js"><link rel="prefetch" href="/docs/assets/js/116.92971223.js"><link rel="prefetch" href="/docs/assets/js/117.c5a65e7e.js"><link rel="prefetch" href="/docs/assets/js/118.e329035d.js"><link rel="prefetch" href="/docs/assets/js/119.cbb17c5e.js"><link rel="prefetch" href="/docs/assets/js/12.c8144ee8.js"><link rel="prefetch" href="/docs/assets/js/120.8537f6a6.js"><link rel="prefetch" href="/docs/assets/js/121.257d3851.js"><link rel="prefetch" href="/docs/assets/js/122.96a5f921.js"><link rel="prefetch" href="/docs/assets/js/123.2220fd12.js"><link rel="prefetch" href="/docs/assets/js/124.552b1a29.js"><link rel="prefetch" href="/docs/assets/js/125.4e36fe37.js"><link rel="prefetch" href="/docs/assets/js/126.3939cdcc.js"><link rel="prefetch" href="/docs/assets/js/127.014df434.js"><link rel="prefetch" href="/docs/assets/js/13.edc237a8.js"><link rel="prefetch" href="/docs/assets/js/14.66270d4f.js"><link rel="prefetch" href="/docs/assets/js/15.0804164b.js"><link rel="prefetch" href="/docs/assets/js/16.dec928ab.js"><link rel="prefetch" href="/docs/assets/js/17.bbfc90a8.js"><link rel="prefetch" href="/docs/assets/js/18.76904860.js"><link rel="prefetch" href="/docs/assets/js/19.80a98011.js"><link rel="prefetch" href="/docs/assets/js/20.c39e42bd.js"><link rel="prefetch" href="/docs/assets/js/21.287b744a.js"><link rel="prefetch" href="/docs/assets/js/22.c9506be7.js"><link rel="prefetch" href="/docs/assets/js/23.9732a229.js"><link rel="prefetch" href="/docs/assets/js/24.21ed1f05.js"><link rel="prefetch" href="/docs/assets/js/25.8f1926f6.js"><link rel="prefetch" href="/docs/assets/js/27.3706753c.js"><link rel="prefetch" href="/docs/assets/js/28.b6b182cf.js"><link rel="prefetch" href="/docs/assets/js/29.ae979ad9.js"><link rel="prefetch" href="/docs/assets/js/3.a7f8dd77.js"><link rel="prefetch" href="/docs/assets/js/30.f2233269.js"><link rel="prefetch" href="/docs/assets/js/31.06780314.js"><link rel="prefetch" href="/docs/assets/js/32.2dad91d1.js"><link rel="prefetch" href="/docs/assets/js/33.87ec6e22.js"><link rel="prefetch" href="/docs/assets/js/34.7b75f220.js"><link rel="prefetch" href="/docs/assets/js/35.3184991f.js"><link rel="prefetch" href="/docs/assets/js/36.28248fbe.js"><link rel="prefetch" href="/docs/assets/js/37.5824a979.js"><link rel="prefetch" href="/docs/assets/js/38.99a364fe.js"><link rel="prefetch" href="/docs/assets/js/39.a5f43732.js"><link rel="prefetch" href="/docs/assets/js/4.a55d89ed.js"><link rel="prefetch" href="/docs/assets/js/40.629f78f7.js"><link rel="prefetch" href="/docs/assets/js/41.e4f58d1c.js"><link rel="prefetch" href="/docs/assets/js/42.9f41aa47.js"><link rel="prefetch" href="/docs/assets/js/43.636412b6.js"><link rel="prefetch" href="/docs/assets/js/44.3b491aef.js"><link rel="prefetch" href="/docs/assets/js/45.77df19bc.js"><link rel="prefetch" href="/docs/assets/js/46.01f53ddd.js"><link rel="prefetch" href="/docs/assets/js/47.476e85c9.js"><link rel="prefetch" href="/docs/assets/js/48.198502dc.js"><link rel="prefetch" href="/docs/assets/js/49.0d59d332.js"><link rel="prefetch" href="/docs/assets/js/5.1597c0f8.js"><link rel="prefetch" href="/docs/assets/js/50.02baf101.js"><link rel="prefetch" href="/docs/assets/js/51.c9fbd54d.js"><link rel="prefetch" href="/docs/assets/js/52.4cb4459b.js"><link rel="prefetch" href="/docs/assets/js/53.248450d7.js"><link rel="prefetch" href="/docs/assets/js/54.83f12d1e.js"><link rel="prefetch" href="/docs/assets/js/55.b18accba.js"><link rel="prefetch" href="/docs/assets/js/56.8a160b09.js"><link rel="prefetch" href="/docs/assets/js/57.b854a940.js"><link rel="prefetch" href="/docs/assets/js/58.4500f315.js"><link rel="prefetch" href="/docs/assets/js/59.59400e36.js"><link rel="prefetch" href="/docs/assets/js/6.887ba020.js"><link rel="prefetch" href="/docs/assets/js/60.4dd5b5bb.js"><link rel="prefetch" href="/docs/assets/js/61.50d8c8f6.js"><link rel="prefetch" href="/docs/assets/js/62.17d10daa.js"><link rel="prefetch" href="/docs/assets/js/63.d5f821cc.js"><link rel="prefetch" href="/docs/assets/js/64.7bf2519f.js"><link rel="prefetch" href="/docs/assets/js/65.0a1c9bc8.js"><link rel="prefetch" href="/docs/assets/js/66.1bcaa81c.js"><link rel="prefetch" href="/docs/assets/js/67.326bdf9b.js"><link rel="prefetch" href="/docs/assets/js/68.2b3b63b2.js"><link rel="prefetch" href="/docs/assets/js/69.c9b1a1a9.js"><link rel="prefetch" href="/docs/assets/js/70.a5fede78.js"><link rel="prefetch" href="/docs/assets/js/71.288d9643.js"><link rel="prefetch" href="/docs/assets/js/72.8665d6b8.js"><link rel="prefetch" href="/docs/assets/js/73.47155429.js"><link rel="prefetch" href="/docs/assets/js/74.4d4738f8.js"><link rel="prefetch" href="/docs/assets/js/75.659a325f.js"><link rel="prefetch" href="/docs/assets/js/76.a263f692.js"><link rel="prefetch" href="/docs/assets/js/77.9d86d59e.js"><link rel="prefetch" href="/docs/assets/js/78.a41b5d88.js"><link rel="prefetch" href="/docs/assets/js/79.5d0fc4cc.js"><link rel="prefetch" href="/docs/assets/js/8.80d0c81d.js"><link rel="prefetch" href="/docs/assets/js/80.01a11f6a.js"><link rel="prefetch" href="/docs/assets/js/81.9c0207d9.js"><link rel="prefetch" href="/docs/assets/js/82.12be8e04.js"><link rel="prefetch" href="/docs/assets/js/83.00fa5f46.js"><link rel="prefetch" href="/docs/assets/js/84.f14cd53c.js"><link rel="prefetch" href="/docs/assets/js/85.e9d7c0d1.js"><link rel="prefetch" href="/docs/assets/js/86.eb78fbbf.js"><link rel="prefetch" href="/docs/assets/js/87.8a31f5ae.js"><link rel="prefetch" href="/docs/assets/js/88.0f10e6dc.js"><link rel="prefetch" href="/docs/assets/js/89.a17253c9.js"><link rel="prefetch" href="/docs/assets/js/9.2fa568cb.js"><link rel="prefetch" href="/docs/assets/js/90.e56bc609.js"><link rel="prefetch" href="/docs/assets/js/91.5277db18.js"><link rel="prefetch" href="/docs/assets/js/92.b0bb8aa7.js"><link rel="prefetch" href="/docs/assets/js/93.cd790b77.js"><link rel="prefetch" href="/docs/assets/js/94.76bbe227.js"><link rel="prefetch" href="/docs/assets/js/95.4f07ca32.js"><link rel="prefetch" href="/docs/assets/js/96.2b1e8485.js"><link rel="prefetch" href="/docs/assets/js/97.e93b3461.js"><link rel="prefetch" href="/docs/assets/js/98.658063a1.js"><link rel="prefetch" href="/docs/assets/js/99.a3642e6d.js">
    <link rel="stylesheet" href="/docs/assets/css/0.styles.efa081cd.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/docs/" class="home-link router-link-active"><!----> <span class="site-name">Guru Note</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----> <svg aria-hidden="true" class="icon search-icon"><use xlink:href="#icon-search"></use></svg></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/docs/layout/" class="nav-link">
  CSS 手册
</a></div><div class="nav-item"><a href="/docs/js/" class="nav-link">
  JavaScript
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="前端进阶" class="dropdown-title"><span class="title">前端进阶</span> <span class="arrow down"></span></button> <button type="button" aria-label="前端进阶" class="mobile-dropdown-title"><span class="title">前端进阶</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>
          前端框架
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/docs/vue/" class="nav-link">
  Vue.js
</a></li><li class="dropdown-subitem"><a href="/docs/react/" class="nav-link">
  React.js
</a></li></ul></li><li class="dropdown-item"><h4>
          拓展语言
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/docs/node/" class="nav-link">
  Node.js
</a></li><li class="dropdown-subitem"><a href="/docs/ts/" class="nav-link">
  TypeScript
</a></li></ul></li></ul></div></div><div class="nav-item"><a href="/docs/devbook/" class="nav-link router-link-active">
  开发手册
</a></div><div class="nav-item"><a href="/docs/exam/" class="nav-link">
  金九银十
</a></div><div class="nav-item"><a href="/docs/message/" class="nav-link">
  留言板
</a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><div class="el-scrollbar"><div class="scrollbar-wrapper el-scrollbar__wrap el-scrollbar__wrap--hidden-default"><div class="el-scrollbar__view"><nav class="nav-links"><div class="nav-item"><a href="/docs/layout/" class="nav-link">
  CSS 手册
</a></div><div class="nav-item"><a href="/docs/js/" class="nav-link">
  JavaScript
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="前端进阶" class="dropdown-title"><span class="title">前端进阶</span> <span class="arrow down"></span></button> <button type="button" aria-label="前端进阶" class="mobile-dropdown-title"><span class="title">前端进阶</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>
          前端框架
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/docs/vue/" class="nav-link">
  Vue.js
</a></li><li class="dropdown-subitem"><a href="/docs/react/" class="nav-link">
  React.js
</a></li></ul></li><li class="dropdown-item"><h4>
          拓展语言
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/docs/node/" class="nav-link">
  Node.js
</a></li><li class="dropdown-subitem"><a href="/docs/ts/" class="nav-link">
  TypeScript
</a></li></ul></li></ul></div></div><div class="nav-item"><a href="/docs/devbook/" class="nav-link router-link-active">
  开发手册
</a></div><div class="nav-item"><a href="/docs/exam/" class="nav-link">
  金九银十
</a></div><div class="nav-item"><a href="/docs/message/" class="nav-link">
  留言板
</a></div> <!----></nav>  <ul class="sidebar-links"><li><a href="/docs/devbook/" aria-current="page" class="sidebar-link">介绍</a></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>开发者小记</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/devbook/note/regex-getting-started.html" class="sidebar-link">正则表达式入门</a></li><li><a href="/docs/devbook/note/lisp-getting-started.html" class="sidebar-link">Lisp 入门</a></li><li><a href="/docs/devbook/note/search-skill.html" class="sidebar-link">搜索引擎常用技巧</a></li><li><a href="/docs/devbook/note/the-http.html" class="sidebar-link">HTTP 相关知识科普</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>环境搭建</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/devbook/setting/node-use.html" class="sidebar-link">Node.js 安装教程</a></li><li><a href="/docs/devbook/setting/cmder-install.html" class="sidebar-link">Cmder 配置教程</a></li><li><a href="/docs/devbook/setting/vscode-and-cmder-use.html" class="sidebar-link">VSCode 与 Cmder 配合使用</a></li><li><a href="/docs/devbook/setting/tool-recommend.html" class="sidebar-link">Windows 常用工具</a></li><li><a href="/docs/devbook/setting/webstorm.html" class="sidebar-link">WebStorm 配置</a></li><li><a href="/docs/devbook/setting/vscode.html" class="sidebar-link">VSCode 配置</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>命令行工具</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/devbook/cli-plugin.html" class="sidebar-link">命令行常用插件</a></li><li><a href="/docs/devbook/cli-hot-key.html" class="sidebar-link">命令行快捷键</a></li><li><a href="/docs/devbook/git-getting-started.html" class="sidebar-link">Git 命令入门</a></li><li><a href="/docs/devbook/git-many-remotely.html" class="sidebar-link">Git 关联多个远程仓库</a></li><li><a href="/docs/devbook/mobile-file.html" class="sidebar-link">文件操作命令</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>博客搭建</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/devbook/hexo-build-blog.html" aria-current="page" class="active sidebar-link">Hexo 搭建博客教程</a></li><li><a href="/docs/devbook/hexo-generate.html" class="sidebar-link">Hexo 生成永久链接</a></li><li><a href="/docs/devbook/hexo-theme.html" class="sidebar-link">Hexo 主题推荐</a></li><li><a href="/docs/devbook/hugo-created-blog.html" class="sidebar-link">Hugo 搭建个人博客</a></li></ul></section></li></ul> </div></div><div class="el-scrollbar__bar is-horizontal"><div class="el-scrollbar__thumb" style="width:0;transform:translateX(0%);ms-transform:translateX(0%);webkit-transform:translateX(0%);"></div></div><div class="el-scrollbar__bar is-vertical"><div class="el-scrollbar__thumb" style="height:0;transform:translateY(0%);ms-transform:translateY(0%);webkit-transform:translateY(0%);"></div></div></div></aside> <main class="page"> <div class="re-page-top"><h1 class="title"><span>Hexo 搭建博客教程</span></h1> <div class="re-page-index"><div class="page-index-title"><span class="open-catalog"><svg aria-hidden="true" class="icon arrow-right"><use xlink:href="#icon-bold-right"></use></svg> <span class="text">目录</span></span></div> <div class="page-index-content"><div class="page-catalog" style="display:none;"><div class="synopsis-wrap"><ul class="synopsis-ul"><li class="synopsis-li"><a href="/docs/devbook/hexo-build-blog.html#在-github-新建一个仓库" class="synopsis-link">在 Github 新建一个仓库</a></li><li class="synopsis-li"><a href="/docs/devbook/hexo-build-blog.html#环境搭建" class="synopsis-link">环境搭建</a></li><li class="synopsis-li"><a href="/docs/devbook/hexo-build-blog.html#配置-config设置" class="synopsis-link">配置_config设置</a></li><li class="synopsis-li"><a href="/docs/devbook/hexo-build-blog.html#发布更新文章" class="synopsis-link">发布更新文章</a><ul class="synopsis-ul"><li class="synopsis-li"><a href="/docs/devbook/hexo-build-blog.html#安装一个拓展工具-用于向-github-推送文章" class="synopsis-link">安装一个拓展工具(用于向 GitHub 推送文章)</a></li><li class="synopsis-li"><a href="/docs/devbook/hexo-build-blog.html#新建一篇文章" class="synopsis-link">新建一篇文章</a></li><li class="synopsis-li"><a href="/docs/devbook/hexo-build-blog.html#生成静态网页" class="synopsis-link">生成静态网页</a></li><li class="synopsis-li"><a href="/docs/devbook/hexo-build-blog.html#开启本地服务器预览" class="synopsis-link">开启本地服务器预览</a></li><li class="synopsis-li"><a href="/docs/devbook/hexo-build-blog.html#部署到-github" class="synopsis-link">部署到 GitHub</a></li></ul></li><li class="synopsis-li"><a href="/docs/devbook/hexo-build-blog.html#更多相关命令" class="synopsis-link">更多相关命令</a></li><li class="synopsis-li"><a href="/docs/devbook/hexo-build-blog.html#拓展内容" class="synopsis-link">拓展内容</a><ul class="synopsis-ul"><li class="synopsis-li"><a href="/docs/devbook/hexo-build-blog.html#文章" class="synopsis-link">文章</a></li></ul></li><li class="synopsis-li"><a href="/docs/devbook/hexo-build-blog.html#永久链接插件" class="synopsis-link">永久链接插件</a></li></ul></div></div></div></div></div> <div class="theme-default-content content__default"><p>需要会使用命令行工具，并且有GitHub账号。
这篇文章的主要目的是记录自己搭建博客时踩的坑，所以可能没那么全面
部分内容来自： <a href="https://hexo.io/zh-cn/docs/" target="_blank" rel="noopener noreferrer">Hexo官方文档<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <h2 id="在-github-新建一个仓库"><a href="#在-github-新建一个仓库" class="header-anchor">#</a> 在 Github 新建一个仓库</h2> <p>名称格式：</p> <div class="language- extra-class"><pre class="language-text"><code>username.github.io
</code></pre></div><blockquote><p>注：username 必须是你的 GitHub 用户名</p></blockquote> <p>在新仓库中点击 Settings 下拉，在 GitHub Pages 中点击 Choose a theme ，随便选择一个主题应用</p> <p>刷新页面会发现 GitHub Pages 中多了一行网址 ，复制这个网址，这个网址就是后面要配置的 URL 的网址</p> <h2 id="环境搭建"><a href="#环境搭建" class="header-anchor">#</a> 环境搭建</h2> <p>安装 Hexo</p> <div class="language- extra-class"><pre class="language-text"><code>npm install -g hexo-cli
</code></pre></div><p>查看当前版本</p> <div class="language-bash extra-class"><pre class="language-bash"><code>hexo version
</code></pre></div><p>博客目录名称</p> <div class="language-bash extra-class"><pre class="language-bash"><code>username.github.io-creator
</code></pre></div><p>在要创建博客的目录下初始化环境</p> <div class="language- extra-class"><pre class="language-text"><code>hexo init
</code></pre></div><p>安装必备的组件</p> <div class="language- extra-class"><pre class="language-text"><code>npm install
</code></pre></div><h2 id="配置-config设置"><a href="#配置-config设置" class="header-anchor">#</a> 配置<code>_config</code>设置</h2> <p>打开博客根目录下的 <code>_config.yml</code> 文件</p> <p>修改其中的一些配置：
<strong>首先修改URL</strong></p> <p>url：你的仓库主页预览网址</p> <p>root：你的仓库名称 (如果是用户名格式填 / 即可，即 username.github.io)</p> <div class="language-yml extra-class"><pre class="language-yml"><code><span class="token comment"># URL</span>
<span class="token comment">## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'</span>
<span class="token key atrule">url</span><span class="token punctuation">:</span> https<span class="token punctuation">:</span>//username.github.io/
<span class="token key atrule">root</span><span class="token punctuation">:</span> /
<span class="token key atrule">permalink</span><span class="token punctuation">:</span> <span class="token punctuation">:</span>year/<span class="token punctuation">:</span>month/<span class="token punctuation">:</span>day/<span class="token punctuation">:</span>title/
<span class="token key atrule">permalink_defaults</span><span class="token punctuation">:</span>
</code></pre></div><p><strong>然后修改 Deployment</strong></p> <p>主要修改 repository 改为你的仓库的下载地址</p> <div class="language-yml extra-class"><pre class="language-yml"><code><span class="token comment"># Deployment</span>
<span class="token comment">## Docs: https://hexo.io/docs/deployment.html</span>
<span class="token key atrule">deploy</span><span class="token punctuation">:</span>
  <span class="token key atrule">type</span><span class="token punctuation">:</span> git
  <span class="token key atrule">repository</span><span class="token punctuation">:</span> git@github.com<span class="token punctuation">:</span>username/username.github.io.git
  <span class="token key atrule">branch</span><span class="token punctuation">:</span> master
</code></pre></div><p><strong>可选设置</strong></p> <p>命令行新建文章时的名称格式为日期</p> <div class="language-yml extra-class"><pre class="language-yml"><code><span class="token key atrule">new_post_name</span><span class="token punctuation">:</span> <span class="token punctuation">:</span>year<span class="token punctuation">-</span><span class="token punctuation">:</span>month<span class="token punctuation">-</span><span class="token punctuation">:</span>day<span class="token punctuation">-</span><span class="token punctuation">:</span>title.md <span class="token comment"># File name of new posts</span>
</code></pre></div><h2 id="发布更新文章"><a href="#发布更新文章" class="header-anchor">#</a> 发布更新文章</h2> <p>在根目录下打开命令行</p> <h3 id="安装一个拓展工具-用于向-github-推送文章"><a href="#安装一个拓展工具-用于向-github-推送文章" class="header-anchor">#</a> 安装一个拓展工具(用于向 GitHub 推送文章)</h3> <div class="language- extra-class"><pre class="language-text"><code>npm i hexo-deployer-git
</code></pre></div><p>详情参考：<a href="https://hexo.io/zh-cn/docs/github-pages#Private-repository" target="_blank" rel="noopener noreferrer">将 Hexo 部署到 GitHub Pages<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <h3 id="新建一篇文章"><a href="#新建一篇文章" class="header-anchor">#</a> 新建一篇文章</h3> <div class="language- extra-class"><pre class="language-text"><code>hexo new post &quot;article title&quot;
</code></pre></div><p>文章的目录在 <code>source\_posts</code>下</p> <h3 id="生成静态网页"><a href="#生成静态网页" class="header-anchor">#</a> 生成静态网页</h3> <div class="language-sh extra-class"><pre class="language-sh"><code>hexo g
<span class="token comment"># 全称：hexo generate</span>
</code></pre></div><h3 id="开启本地服务器预览"><a href="#开启本地服务器预览" class="header-anchor">#</a> 开启本地服务器预览</h3> <div class="language-sh extra-class"><pre class="language-sh"><code>hexo s
<span class="token comment"># 全称：hexo server</span>
</code></pre></div><h3 id="部署到-github"><a href="#部署到-github" class="header-anchor">#</a> 部署到 GitHub</h3> <div class="language-sh extra-class"><pre class="language-sh"><code>hexo d
<span class="token comment"># 全称：hexo deploy</span>
</code></pre></div><h2 id="更多相关命令"><a href="#更多相关命令" class="header-anchor">#</a> 更多相关命令</h2> <p><strong>清除文件缓存</strong></p> <div class="language- extra-class"><pre class="language-text"><code>hexo clean
</code></pre></div><p><strong>删除 hexo</strong></p> <p>3.0.0版本执行</p> <div class="language-text extra-class"><pre class="language-text"><code>npm uninstall hexo-cli -g
</code></pre></div><p>之前版本执行</p> <div class="language-text extra-class"><pre class="language-text"><code>npm uninstall hexo -g
</code></pre></div><h2 id="拓展内容"><a href="#拓展内容" class="header-anchor">#</a> 拓展内容</h2> <p>以下是拓展内容，可不看</p> <h3 id="文章"><a href="#文章" class="header-anchor">#</a> 文章</h3> <p><strong>文件名称</strong></p> <p>Hexo 默认以标题做为文件名称，但您可编辑 <code>new_post_name</code> 参数来改变默认的文件名称，</p> <p>举例来说，它的默认值是 <code>:title.md</code>，你可以更改为 <code>:year-:month-:day-:title.md</code> 可让您更方便的通过日期来管理文章。</p> <table><thead><tr><th style="text-align:left;">变量</th> <th style="text-align:left;">描述</th></tr></thead> <tbody><tr><td style="text-align:left;"><code>:title</code></td> <td style="text-align:left;">标题（小写，空格将会被替换为短杠）</td></tr> <tr><td style="text-align:left;"><code>:year</code></td> <td style="text-align:left;">建立的年份，比如， <code>2015</code></td></tr> <tr><td style="text-align:left;"><code>:month</code></td> <td style="text-align:left;">建立的月份（有前导零），比如， <code>04</code></td></tr> <tr><td style="text-align:left;"><code>:i_month</code></td> <td style="text-align:left;">建立的月份（无前导零），比如， <code>4</code></td></tr> <tr><td style="text-align:left;"><code>:day</code></td> <td style="text-align:left;">建立的日期（有前导零），比如， <code>07</code></td></tr> <tr><td style="text-align:left;"><code>:i_day</code></td> <td style="text-align:left;">建立的日期（无前导零），比如， <code>7</code></td></tr></tbody></table> <p><strong>Front-matter</strong></p> <p>Front-matter 是文件最上方以 <code>---</code> 分隔的区域，用于指定个别文件的变量，举例来说：</p> <div class="language- extra-class"><pre class="language-text"><code>---
title: Hello World
date: 2013/7/13 20:46:25
---
</code></pre></div><p>以下是预先定义的参数，您可在模板中使用这些参数值并加以利用。</p> <table><thead><tr><th style="text-align:left;">参数</th> <th style="text-align:left;">描述</th> <th style="text-align:left;">默认值</th></tr></thead> <tbody><tr><td style="text-align:left;"><code>layout</code></td> <td style="text-align:left;">布局</td> <td style="text-align:left;"></td></tr> <tr><td style="text-align:left;"><code>title</code></td> <td style="text-align:left;">标题</td> <td style="text-align:left;"></td></tr> <tr><td style="text-align:left;"><code>date</code></td> <td style="text-align:left;">建立日期</td> <td style="text-align:left;">文件建立日期</td></tr> <tr><td style="text-align:left;"><code>updated</code></td> <td style="text-align:left;">更新日期</td> <td style="text-align:left;">文件更新日期</td></tr> <tr><td style="text-align:left;"><code>comments</code></td> <td style="text-align:left;">开启文章的评论功能</td> <td style="text-align:left;">true</td></tr> <tr><td style="text-align:left;"><code>tags</code></td> <td style="text-align:left;">标签（不适用于分页）</td> <td style="text-align:left;"></td></tr> <tr><td style="text-align:left;"><code>categories</code></td> <td style="text-align:left;">分类（不适用于分页）</td> <td style="text-align:left;"></td></tr> <tr><td style="text-align:left;"><code>permalink</code></td> <td style="text-align:left;">覆盖文章网址</td> <td style="text-align:left;"></td></tr> <tr><td style="text-align:left;"><code>keywords</code></td> <td style="text-align:left;">仅用于 meta 标签和 Open Graph 的关键词（不推荐使用）</td> <td style="text-align:left;"></td></tr></tbody></table> <p><strong>添加文章描述</strong></p> <p>在文章头部的 Front-matter 中添加 <code>description</code> 属性来添加描述，如果没有这个属性，默认会自动截取文章内容作为文章的描述。</p> <p><strong>给文章添加标签分类</strong></p> <p>只有文章支持分类和标签，您可以在 Front-matter 中设置。在其他系统中，分类和标签听起来很接近，但是在 Hexo 中两者有着明显的差别：分类具有顺序性和层次性，也就是说 <code>Foo, Bar</code> 不等于 <code>Bar, Foo</code>；而标签没有顺序和层次。</p> <div class="language- extra-class"><pre class="language-text"><code>categories:
- Diary
tags:
- PS3
- Games
</code></pre></div><p><strong>删除标签</strong></p> <p>首先把每篇文章中那个标签的属性去除，然后执行以下命令，清除之前的缓存</p> <div class="language- extra-class"><pre class="language-text"><code>hexo clean
</code></pre></div><p>然后再次 <code>hexo g</code> 生页面成即可</p> <h2 id="永久链接插件"><a href="#永久链接插件" class="header-anchor">#</a> 永久链接插件</h2> <p>插件地址：https://github.com/rozbo/hexo-abbrlink</p> <blockquote><p>使用方法见文档</p></blockquote> <p><strong>给文章添加 favicon.ico 图标</strong></p> <p>首先修改主题文件夹的配置信息：</p> <p>在根目录 <code>根目录/themes/xxx/_config.yml</code></p> <p>找到 favicon 并修改为以下路径：</p> <div class="language- extra-class"><pre class="language-text"><code>favicon: favicon.ico
</code></pre></div><p>然后将准备好的 <code>favicon.ico</code> 图标放到 <code>hexo/themes/xxx/source</code> 路径下即可</p> <blockquote><p>注：xxx 表示你的主题文件的路径，博客主题文件都存放在 <code>根目录/themes</code>下</p> <p>ico 图标转换网站转换：http://www.bitbug.net/</p></blockquote> <p><strong>VSC 安装 stylus 语法高亮</strong></p> <p>搜索插件：<code>language-stylus</code></p> <blockquote><p>使用VSC修改主题样式可以安装</p></blockquote></div> <footer class="page-edit"><!----> <div class="last-updated"><span class="prefix">上次更新：</span><span class="time">2021-02-10 12:44</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev"><svg aria-hidden="true" class="icon"><use xlink:href="#icon-left"></use></svg> <a href="/docs/devbook/mobile-file.html" class="prev">文件操作命令</a></span> <span class="next"><a href="/docs/devbook/hexo-generate.html">Hexo 生成永久链接</a> <svg aria-hidden="true" class="icon"><use xlink:href="#icon-right"></use></svg></span></p></div> </main></div><div class="global-ui"><!----><!----></div></div>
    <script src="/docs/assets/js/app.cdec4db9.js" defer></script><script src="/docs/assets/js/2.993bd611.js" defer></script><script src="/docs/assets/js/26.61b6eb9f.js" defer></script><script src="/docs/assets/js/7.5a12abef.js" defer></script>
  </body>
</html>
